﻿using System;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.Core;

namespace Yuanlin.Business
{
    public class MiaomuCategoryList : YuanlinUserControl,
        IReplyConverter<MiaomuCategoryReply, GetListOperation>
    {
        protected Repeater list;
        private EntityList miaomuCategorys;
        public int categoryType = UrlManager.Instance.GetParameterValue<int>(YuanlinParameterName.CategoryType);

        public override void GetRequests(List<BaseRequestBinder> requestBinders)
        {
            if (!Page.IsPostBack)
            {
                requestBinders.Add(RequestHelper.BuildGetMiaomuCategoryListRequest(this));
            }
        }

        private void BindData()
        {
            this.list.DataSource = miaomuCategorys;
            this.list.DataBind();
        }

        #region IReplyConverter<MiaomuCategoryReply,GetListOperation> Members

        public void ConvertReply(MiaomuCategoryReply reply, GetListOperation operation)
        {
            if (reply != null)
            {
                miaomuCategorys = reply.EntityList;

                if (!Page.IsPostBack)
                {
                    BindData();
                }
            }
        }

        #endregion
    }
}
